<!-- banner -->
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>轮播图</title>
        <style>
        *{
            margin: 0px;
            padding: 0px;
            list-style: none;
        }
        /* .lunbo{
            position:relative;
            /* right: 0px; */
            /* top: 70px; */
            /* width: 490px;
            height: 280px;
            float: right;
            background: pink;
        } */ 
        .pic{
            width: 490px;
            height: 280px;
            margin:100px auto;
            border-radius: 10px;
            background: pink;
            position: relative;
            overflow: hidden;
        }
         ul{
            width: 9999px;
            overflow: hidden;
        }
         ul li{
            float: left;
            cursor: pointer;
        }
        
        ol{
            position: absolute;
            bottom: 10px;
            left: 50%;
            transform: translateX(-50%);
        }
        ol li{
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: white;
            float: left;
            margin: 0px 4px;
            cursor: pointer;
        }
         span{
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            background: gray;
            border-radius: 50%;
            width: 30px;
            line-height: 30px;
            text-align: center;
            height: 30px;
            display: block;
            color: white;
            font-size: 30px;
            cursor: pointer;
            opacity:0.5;
        }
        .tleft{
            left: 5px
        }
        .tright{
            right: 5px
        }
        .current{
            background: #609700;
        }
        </style>
    </head>
    <body>

            <div class="pic" id="wit">

                <ul id="box">
                    <li><img src="images/gundong1.png" alt=""></li>
                    <li><img src="images/gundong2.png" alt=""></li>
                    <li><img src="images/gundong3.png" alt=""></li>
                </ul>

                <ol id="list">
                    <li class="current"></li>
                    <li></li>
                    <li></li>
                </ol>

                <span class="tleft" id="tleft"><</span>
                <span class="tright" id="tright">></span>
            
        
            <script>
                var box=document.getElementById('box');
                var wit=document.getElementById('wit');
                var list=document.getElementById('list').children;
                var tleft=document.getElementById('tleft');
                var tright=document.getElementById('tright');
                var num=0;
                var timer; 
                function fn(){
                    timer=setInterval(function(){
                    num++;
                    if(num>2){
                        num=0;
                    }
        
                    for(var j=0;j<list.length;j++){
                            list[j].className='';
                        }
                    
                    list[num].className='current';
                    n=-490*num;
                    box.style.transform='translateX('+n+'px)'
                    box.style.transition='all 1s'
                },2000)
                }
        
                fn()
        
                wit.onmouseenter=function(){
                    clearInterval(timer)
                }
                wit.onmouseleave=function(){
                   fn()
                }
                for(var i=0;i<list.length;i++){
                    list[i].index=i;
                    list[i].onclick=function(){
                        for(var j=0;j<list.length;j++){
                            list[j].className=''
                        }
                        this.className='current';
                        num=this.index;
                    n=-490*num;
                    box.style.transform='translateX('+n+'px)'
                    box.style.transition='all 1s'
                    }
                }
                tright.onclick=function(){
                    num++;
                    if(num>2){
                        num=0;
                    }
        
                    for(var j=0;j<list.length;j++){
                            list[j].className='';
                        }
                    
                    list[num].className='current';
                    n=-490*num;
                    box.style.transform='translateX('+n+'px)'
                    box.style.transition='all 1s'
                }
                tleft.onclick=function(){
                    num--;
                    if(num<0){
                        num=2;
                    }
        
                    for(var j=0;j<list.length;j++){
                            list[j].className='';
                        }
                    
                    list[num].className='current';
                    n=-490*num;
                    box.style.transform='translateX('+n+'px)'
                    box.style.transition='all 1s'
                }
            </script>
            </div>
    </body>
</html>